import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { StudentVo } from '../vo/student-vo';

@Injectable()
export class StudentService {

  constructor(private http:HttpClient) { }


  private getAnObjectUrl="http://localhost/getAnObject";

  getAnObject(){

    return this.http.get(this.getAnObjectUrl).toPromise();
  }

  private addStudentUrl="http://localhost/saveStudentInfo";

addStudentInfo(svo:StudentVo){
let p={
  "studentid":svo.studentid,
	"xm":svo.xm,
	"sfzh":svo.sfzh,
	"xh":svo.xh
}

return this.http.post(this.addStudentUrl,p).toPromise();



}


   private getStudentListUrl="http://localhost/getStudentList";

   getStudentList(){

   return this.http.get(this.getStudentListUrl).toPromise();

   }

   private getSingleStudentByIdUrl="http://localhost/getSingleStudentById";

   getSingleStudentById(id:string){
   let p={
    "studentid":id
   }

   return this.http.post(this.getSingleStudentByIdUrl,p).toPromise();


   }

   private deleteStudentUrl="http://localhost/deleteStudent";
   deleteStudent(id:string){
   let p={
     "studentid":id
   }

   return this.http.post(this.deleteStudentUrl,p).toPromise();


   }




}
